<?php
	include("../../include/dbconnect.php");
	extract($_POST);

	$table="dghang";
	$table_title="đơn giá cho hàng";
	$table_title_u="Đơn giá cho hàng";

	session_start();
	header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
	echo "<$table>";
	if($_SESSION["un"]=="")
	{
		echo "<status>fail</status>";
		echo "<count>0</count>";
		echo "<message>Chưa đăng nhập !</message>";
	}
	else 
	{
		$count=0;
		$result="";
		$rs=mysql_query("select * from dvthang where idhang=$idhang",$conn);
		while($a=mysql_fetch_array($rs))
		{
			
			$iddvthang=$a["id"];
			$sql="select * from $table where ";
			$sql=$sql."idhang=$idhang and iddvthang=$iddvthang and ";
			$sql=$sql."ngay<=CURRENT_TIMESTAMP ";
			$sql=$sql."order by ngay desc";
			$rs1=mysql_query($sql,$conn);
			
			if($a1=mysql_fetch_array($rs1))
			{
				$count++;
				$result=$result."<id>".$a1["id"]."</id>";
			}
			mysql_free_result($rs1);
		}
		mysql_free_result($rs);
		if($count>0)
		{
			echo "<status>ok</status>";
			echo "<message>OK</message>";
			echo $result;
		}
		else
		{
			echo "<status>fail</status>";
			echo "<message>Không có $table_title cho thời điểm hiện tại !</message>";
		}
	}

	echo "</$table>";
	include("../../include/dbclose.php");
?>
